﻿// -------------------------------------------------------------------------
//    @FileName         :    NF1v1Part.cpp
//    @Author           :    gaoyi
//    @Date             :    24-8-30
//    @Email            :    445267987@qq.com
//    @Module           :    NF1v1Part
//
// -------------------------------------------------------------------------

#include "NF1v1Part.h"

#include <NFGlobalMiscData.h>

#include "proto_cs_login.pb.h"
#include "proto_db.pb.h"

NF1v1Part::NF1v1Part()
{
    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
    {
        CreateInit();
    }
    else
    {
        ResumeInit();
    }
}

NF1v1Part::~NF1v1Part()
{
}

int NF1v1Part::CreateInit()
{
    return 0;
}
    
int NF1v1Part::ResumeInit()
{
    return 0;
}


int NF1v1Part::LoadFromDB(const proto_ff::tbRoleDetail *pDBData)
{
    m_stData.FromPb(pDBData->role_play_data().pvp_1v1_data());
    return 0;
}

int NF1v1Part::InitConfig(proto_ff::tbRoleDetail *pDbData, const RoleOne& stRoleOne)
{
    CHECK_NULL(0, pDbData);
    auto pData = pDbData->mutable_role_play_data()->mutable_pvp_1v1_data();
    CHECK_NULL(0, pData);

    const PvP1v1GlobalData *pSeasonData = NFGlobalMiscData::Instance()->GetPvPGlobalData();

    pData->set_season(pSeasonData->season);
    pData->set_grade(MIN_PVP_1V1_GRADE);
    pData->set_mmr(INIT_PVP_1V1_MMR);
    return 0;
}

int NF1v1Part::SaveDB(proto_ff::tbRoleDetail *pDBData)
{
    m_stData.ToPb(pDBData->mutable_role_play_data()->mutable_pvp_1v1_data());
    return 0;
}

int NF1v1Part::SaveRoleSimpleInfo(proto_ff::Proto_RoleSimpleInfo* pDbData)
{
    CHECK_NULL(0, pDbData);
    pDbData->set_division(m_stData.grade);
    return 0;
}

int NF1v1Part::MakePlayerDataCS(proto_ff::Proto_CSGetRoleRsp* pCSGetRoleRsp)
{
    m_stData.ToPb(pCSGetRoleRsp->mutable_pvp_1v1_data());
    return 0;
}

int NF1v1Part::MakeCityPlayerData(proto_ff::CityRoleInfo* pGCCityRoleInfo)
{
    return 0;
}
